<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="*|/">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="text()|@*">
    <xsl:value-of select="."/>
  </xsl:template>

  <xsl:template match='nbsp' name='nbsp'>
    <xsl:text disable-output-escaping='yes'>&amp;nbsp;</xsl:text>
  </xsl:template>

  <xsl:template name="rangeRecursive">
    <xsl:param name="index" select="1"/>
    <xsl:param name="selected" select="1"/>
    <xsl:param name="limit" select="31"/>
    <xsl:choose>
      <xsl:when test='$index = $selected'>
        <option value="{$index}" selected="true">
          <xsl:value-of select="$index"/>
        </option>
      </xsl:when>
      <xsl:otherwise>
        <option value="{$index}">
          <xsl:value-of select="$index"/>
        </option>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:if test="$index &lt; $limit">
      <xsl:call-template name="rangeRecursive">
        <xsl:with-param name="index" select="$index + 1"/>
        <xsl:with-param name="selected" select="$selected"/>
        <xsl:with-param name="limit" select="$limit"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>

  <xsl:template match="Registration/Step3">

    <script type="text/javascript">


    </script>

    <script>
      function validateForm() {

      document.returnValue = false;

      var statura = document.getElementById("D302").value;
      if (!isPositiveInteger(statura )){
      alert("Inserisci una statura valida, dai!");
      return false;
      }else{
      document.returnValue = true;
      }

      document.returnValue = false;
      var peso = document.getElementById("D303").value;

      if (!isPositiveInteger(peso )){
      alert("Inserisci un peso valido, dai!");
      return false;
      }else{
      document.returnValue = true;
      }      
      }


    </script>

    <form name="formRegistration" id="formRegistration" method="post" action="registration2.aspx?step=4" onSubmit="validateForm();return document.returnValue">
      <center>
        <div class="round_me" style="text-align: left; background:#FEEECC; padding:20px; margin:10px; width:75%;">
          <table class="body" border="0">
          <tr>
            <td class='title' colspan='2'>
              <xsl:value-of select="@title"/>
              <input type="hidden" name="newlyCreatedUserid" value="{/Registration/@newlyCreatedUserid}"/>
            </td>
          </tr>
        <xsl:for-each select='Question'>
          <xsl:choose>
            <xsl:when test='@id="301"'>
              <tr>
                <td>
                  <xsl:value-of select="@description"/>
                </td>
                <td>
                  <select size="1" name="D{@id}">
                    <xsl:for-each select="Answer">
                      <option value="{@id}">
                        <xsl:value-of select="."/>
                      </option>
                    </xsl:for-each>
                  </select>
                </td>
              </tr>
            </xsl:when>
            <xsl:when test='@id="302"'>
              <tr>
                <td>
                  <xsl:value-of select="@description"/>
                </td>
                <td>
                  <select name="D{@id}" id="D{@id}">
                    <option value="none" selected="true" disabled="true">
                      altezza
                    </option>
                    <option value="" disabled="true">
                      ----
                    </option>
                    <xsl:call-template name="rangeRecursive">
                      <xsl:with-param name="index" select="140"/>
                      <xsl:with-param name="selected" select="270"/>
                      <xsl:with-param name="limit" select="210"/>
                    </xsl:call-template>
                  </select>
                </td>
              </tr>
            </xsl:when>
            <xsl:when test='@id="303"'>
              <tr>
                <td>
                  <xsl:value-of select="@description"/>
                </td>
                <td>
                  <select name="D{@id}" id="D{@id}">
                    <option value="none" selected="true" disabled="true">
                      peso
                    </option>
                    <option value="" disabled="true">
                      ----
                    </option>
                    <xsl:call-template name="rangeRecursive">
                      <xsl:with-param name="index" select="40"/>
                      <xsl:with-param name="selected" select="270"/>
                      <xsl:with-param name="limit" select="160"/>
                    </xsl:call-template>
                  </select>
                </td>
              </tr>
            </xsl:when>
            <xsl:when test='@id="304"'>
              <tr>
                <td>
                  <xsl:value-of select="@description"/>
                </td>
                <td>
                  <select size="1" name="D{@id}">
                    <xsl:for-each select="Answer">
                      <option value="{@id}">
                        <xsl:value-of select="."/>
                      </option>
                    </xsl:for-each>
                  </select>
                </td>
              </tr>
            </xsl:when>
            <xsl:when test='@id="305"'>
              <tr>
                <td>
                  <xsl:value-of select="@description"/>
                </td>
                <td>
                  <select size="1" name="D{@id}">
                    <xsl:for-each select="Answer">
                      <option value="{@id}">
                        <xsl:value-of select="."/>
                      </option>
                    </xsl:for-each>
                  </select>
                </td>
              </tr>
            </xsl:when>
            <xsl:when test='@id="306"'>
              <tr>
                <td>
                  <xsl:value-of select="@description"/>
                </td>
                <td>
                  <select size="1" name="D{@id}">
                    <xsl:for-each select="Answer">
                      <option value="{@id}">
                        <xsl:value-of select="."/>
                      </option>
                    </xsl:for-each>
                  </select>
                </td>
              </tr>
            </xsl:when>
            <xsl:when test='@id="307"'>
              <tr>
                <td>
                  <xsl:value-of select="@description"/>
                </td>
                <td>
                  <select size="1" name="D{@id}">
                    <xsl:for-each select="Answer">
                      <option value="{@id}">
                        <xsl:value-of select="."/>
                      </option>
                    </xsl:for-each>
                  </select>
                </td>
              </tr>
            </xsl:when>
            <xsl:when test='@id="308"'>
              <tr>
                <td>
                  <xsl:value-of select="@description"/>
                </td>
                <td>
                  <select size="1" name="D{@id}">
                    <xsl:for-each select="Answer">
                      <option value="{@id}">
                        <xsl:value-of select="."/>
                      </option>
                    </xsl:for-each>
                  </select>
                </td>
              </tr>
            </xsl:when>
            <xsl:when test='@id="309"'>
              <tr>
                <td>
                  <xsl:value-of select="@description"/>
                </td>
                <td>
                  <select size="1" name="D{@id}">
                    <xsl:for-each select="Answer">
                      <option value="{@id}">
                        <xsl:value-of select="."/>
                      </option>
                    </xsl:for-each>
                  </select>
                </td>
              </tr>
            </xsl:when>


          </xsl:choose>
        </xsl:for-each>

        <tr>
          <td colspan='2' align='center' style='padding-top:20px;padding-bottom:20px;'>
            <p class="submit">
              <input type="submit" id="signup_submit" name="subbutton" value="{@SubmitButton}"></input>
            </p>
          </td>

        </tr>
        </table>
        </div>
        </center>
      </form>

  </xsl:template>

</xsl:stylesheet>